<template>hello</template>
<script setup lang="ts">
import { onMounted } from "vue";
const testEventLoop = () => {
  function log(str: string) {
    console.log(str);
  }
  async function fn1() {
    log("fn1 start");
    await fn2();
    log("fn1 end");
  }
  async function fn2() {
    log("fn2");
  }
  log("script start");
  setTimeout(() => {
    log("setTimeout");
  }, 0);
  fn1();
  new Promise((resolve, reject) => {
    log("promise start");
    resolve();
  }).then(() => {
    log("then");
  });
  log("script end");
};
function DanliModel(this: any, name: undefined) {
  this.name = name;
}
DanliModel.prototype.getName = function () {
  return this.name;
};
DanliModel.prototype.getInstance = (function () {
  let instance: null = null;
  return function (name: any) {
    if (!instance) {
      instance = new DanliModel(name);
    }
    return instance;
  };
})();
const checkDanli = () => {
  const a = new DanliModel().getInstance("a");
  const b = new DanliModel().getInstance("b");
  console.log(a);
  console.log(b);
};
onMounted(() => {
  testEventLoop();
  checkDanli();
});
</script>
